<template>
  <Modal :title="title" v-model="visible" width="920" :footer-hide="true" @on-cancel="visible = false">
    <Card>
      <div>鉴定标题：{{form.title}}</div>
      <Divider />
      <div>内容：{{form.content}}</div>
      <Divider />
      <div>发布人：{{ form.username }}</div>
      <Divider />
      <div style="display: flex;">
        <div>“山”票数：{{ form.shanCount }}</div>
        <div style="margin-left: 30px;">“正”票数：{{ form.zhengCount }}</div>
      </div>
      <Divider />
      <div>鉴定结果：{{ form.authenticateResult }}</div>
    </Card>
  </Modal>
</template>

<script>
import { getAppraisalDetailById } from '@/api/new.js';
export default {
  name: 'postDetail',
  props: {
    value: {
      type: Boolean,
      default: false
    },
    data: {
      type: Object
    }
  },
  data() {
    return {
      visible: this.value,
      title: '',
      submitLoading: false,
      maxHeight: 510,
      form: {}
    };
  },
  methods: {
    setCurrentValue(value) {
      // console.log(this.form)
      console.log(value)
      // console.log(data)
      if (value === this.visible) {
        return;
      }
      this.title = '查看详情';
      // 回显
      getAppraisalDetailById({ id: this.data.id }).then(res => {
        if (res.code === 200) {
          this.form = res.data;
          this.visible = value;
        }
      })
    }
  },
  watch: {
    value(val) {
      this.setCurrentValue(val);
    },
    visible(value) {
      this.$emit('input', value);
    }
  },
  mounted() {
    // this.init();
  }
};
</script>

<style lang="less">
@import '../../../styles/drawer-common.less';
</style>
